﻿// --------------------------------------------------------------------------------------------------------------------
// <copyright company="Microsoft Corp." file="CreateHostedServiceCommand.cs">
//   All rights reserved. See License.txt in the project root for license information.
// </copyright>
// 
// --------------------------------------------------------------------------------------------------------------------
namespace AzureManagement.AzureCommands
{
    using System;

    using AzureManagement.AzureDataContracts;

    using Common;

    using RestClient;

    public class CreateHostedServiceCommand : AzureManagementCommand
    {
        private readonly CreateHostedService createHostedService;

        public CreateHostedServiceCommand(IAzureServiceContext serviceContext, CreateHostedService createHostedService)
            : base(serviceContext)
        {
            if (createHostedService == null)
            {
                throw new ArgumentNullException("createHostedService", "Hosted service parameters must not be null.");
            }

            this.createHostedService = createHostedService;
        }

        protected override RequestContext GetRequestContext()
        {
            return this.CreatePostOperationRequestContext();
        }

        protected override string FormatPath(IAzureServiceContext azureServiceContext)
        {
            return string.Format("{0}/services/hostedservices", azureServiceContext.SubscriptionId);
        }

        protected override string FormatBody()
        {
            return XmlHelper.Serialize(this.createHostedService);
        }
    }
}